﻿<%@ WebHandler Language="C#" Class="SYS_Product_single" %>

using System;
using System.Web;
using System.Web.Script.Serialization;
using System.Data;
using System.Collections.Generic;
using System.Web.SessionState;

public class SYS_Product_single : IHttpHandler,IRequiresSessionState {
    sqlhelp sql = new sqlhelp();
    SYS_ProductSingleresult result = new SYS_ProductSingleresult();
    string str = "";
    DataTable dt = new DataTable();
	string sort = "createTime";
    string sorttype = "desc";
    public void ProcessRequest (HttpContext context) {
        try
        {
            if (context.Session["comid"] == null)
            {
                result.code = "-1";
                result.msg = "用户未登录";
                unit.send(context, result);
                return;
            }
            string where = " and Enable = 1 ";
            result.code = "1";
            string Id = "";
            if (context.Request["Id"] != null)
            {
                Id = context.Request["Id"].ToString();
                where = where + " and Id = '" + Id + "'";
            }
            else {
                result.code = "0";
                result.msg = "未传递商品ID";
                unit.send(context, result);
                return;
            }
            
            dt = sql.myDataSet("select * from SYS_Product where 1 = 1 " + where).Tables[0];
            
			int len = dt.Rows.Count;
			if (len > 0)
			{
                SYS_ProductSingle _SYS_Product = new SYS_ProductSingle();
                _SYS_Product.Id = dt.Rows[0]["Id"].ToString();
                _SYS_Product.Code = dt.Rows[0]["Code"].ToString();
                _SYS_Product.StoreId = dt.Rows[0]["StoreId"].ToString();
                _SYS_Product.CategoryId = dt.Rows[0]["CategoryId"].ToString();
                _SYS_Product.BannerId = dt.Rows[0]["BannerId"].ToString();
                _SYS_Product.Title = dt.Rows[0]["Title"].ToString();
                _SYS_Product.SubTitle = dt.Rows[0]["SubTitle"].ToString();
                _SYS_Product.AveragePrice = dt.Rows[0]["AveragePrice"].ToString();
                _SYS_Product.Price = dt.Rows[0]["Price"].ToString();
                _SYS_Product.ActivityPrice = dt.Rows[0]["ActivityPrice"].ToString();
                _SYS_Product.Cover = dt.Rows[0]["Cover"].ToString();
                _SYS_Product.DetailText = dt.Rows[0]["DetailText"].ToString();
                _SYS_Product.DetailImgId = dt.Rows[0]["DetailImgId"].ToString();
                _SYS_Product.CreateTime = dt.Rows[0]["CreateTime"].ToString();
                _SYS_Product.Enable = dt.Rows[0]["Enable"].ToString();


                result.data = _SYS_Product;
            }
            else
            {
                result.code = "0";
                result.msg = "无数据";
            }

            }
            catch (Exception e1)
            {
                result.code = "0";
                result.msg = e1.Message;
            }
        unit.send(context, result);
    }

    public bool IsReusable {
        get {
            return false;
        }
    }

}

public class SYS_ProductSingleresult : result
{
    public SYS_ProductSingle data = new SYS_ProductSingle();

}

public class SYS_ProductSingle {
    public string Id = "";
    public string Code = "";
    public string StoreId = "";
    public string CategoryId = "";
    public string BannerId = "";
    public string Title = "";
    public string SubTitle = "";
    public string AveragePrice = "";
    public string Price = "";
    public string ActivityPrice = "";
    public string CreateTime = "";
    public string Enable = "";
    public string Cover = "";
    public string DetailText = "";
    public string DetailImgId = "";
}
